/*
 * RecentFiles.java
 * 
 * last update: 14.01.2010 by Stefan Saru
 * 
 * author:	Felix(felix@ulise.cs.pub.ro)
 * 			Luci
 *
 * Obs: N/A
 */
package ide;

import java.io.*;
import java.util.*;


@SuppressWarnings("serial")
class RecentFiles implements Serializable {
	public int MAXFILES = 10;
	public int number = 0;
	public boolean isEmpty = true;
	String[] sArray = new String[MAXFILES + 1];

	public RecentFiles() {
		number = 0;
	}

	public String getName(int index) {
		if (index <= MAXFILES)return (String) sArray[index];
		else return "error. index out of bounds.";
	}

	public void addName(String name) {
		System.out.println("nr:" + number + " " + name);
		for (int k= 1; k <= number; k++) 
			if (sArray[k].equals(name)) return;
		if (number + 1 <= MAXFILES) sArray[++number] = name;
		else {
			for (int i = 2; i <= MAXFILES; i++) sArray[i - 1] = sArray[i];
			sArray[number] = name;
		}   
	}

	/*public static void main(String args[]) {
  RecentFiles rf = new RecentFiles();
  rf.addName("1");
  rf.addName("2");
  rf.addName("3");
  rf.addName("4");
  rf.addName("5");
  rf.addName("6");
  rf.addName("7");
  rf.addName("8");

  for (int i = 1; i <= rf.number; i++) System.out.println(i + " " + rf.getName(i));


}

	 */

}
